﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Solidi
{
	sealed class ListDependency : IDependency, IDependencyLifestyle
	{
		private Func<IDependencyContainer, object> _factory;
		private IDependencyKey _key;

		public ListDependency(Func<IDependencyContainer, object> factory, IDependencyKey key)
		{
			_factory = factory;
			_key = key;
		}

		public IDependencyKey Key { get { return _key; } }

		public Func<IDependencyContainer, IDependency, object> Factory
		{
			get
			{
				return (c, p) => _factory(c);
			}
		}

		public IDependencyLifestyle Lifestyle { get { return this; } }

		public object AcquireToken(object graphId)
		{
			return graphId;
		}

		public bool DiscardToken(object token)
		{
			return true;
		}

		public Action<object> Disposer { get { return instance => { }; } }

		public IEnumerable<IDependencyParameter> Parameters { get { yield break; } }
	}
}
